﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace AspAuthentication.Persistence
{
    /// <summary>
    /// Defines the contract which any implementation of IUnitOfWork must satisfy
    /// </summary>
    public interface IUnitOfWork
    {
        /// <summary>
        /// Creates the specified domain base object.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="domainBaseObject">The domain base object.</param>
        /// <returns></returns>
        T Create<T>(T domainBaseObject) where T : class;
        /// <summary>
        /// Creates the specified domain base objects.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="domainBaseObjects">The domain base objects.</param>
        /// <returns></returns>
        IList<T> Create<T>(IList<T> domainBaseObjects) where T : class;
        /// <summary>
        /// Updates the specified domain base object.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="domainBaseObject">The domain base object.</param>
        /// <returns></returns>
        T Update<T>(T domainBaseObject) where T : class;
        /// <summary>
        /// Updates the specified domain base objects.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="domainBaseObjects">The domain base objects.</param>
        /// <returns></returns>
        IList<T> Update<T>(IList<T> domainBaseObjects) where T : class;
        /// <summary>
        /// Retrieves the domain object.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="predicate">The predicate.</param>
        /// <returns></returns>
        T RetrieveDomainObject<T>(Expression<Func<T, bool>> predicate = null) where T : class;
        /// <summary>
        /// Searches the specified predicate.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="predicate">The predicate.</param>
        /// <returns></returns>
        IList<T> Search<T>(Expression<Func<T, bool>> predicate = null) where T : class;
        /// <summary>
        /// Deletes the domain user.
        /// </summary>
        /// <param name="username">The username.</param>
        void DeleteDomainUser(string username);
        /// <summary>
        /// Deletes the domain role.
        /// </summary>
        /// <param name="rolename">The rolename.</param>
        void DeleteDomainRole(string rolename);
        /// <summary>
        /// Deletes the profiles.
        /// </summary>
        /// <param name="userNames">The user names.</param>
        void DeleteProfiles(string[] userNames);
        /// <summary>
        /// Executes the SQL.
        /// </summary>
        /// <param name="sqlCommand">The SQL command.</param>
        void ExecuteSql(string sqlCommand);
        /// <summary>
        /// Retrieves the entities from database.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sqlCommand">The SQL command.</param>
        /// <returns></returns>
        IList<T> RetrieveEntitiesFromDatabase<T>(string sqlCommand) where T : class;
    }
}